#include "vcd-sys-info.h"
#include "vcd-display.h"
#include "vcd-sound.h"
#include "vcd-login-setting.h"
#include "vcd-sys-upgrade.h"
#include "vcd-setting-main.h"
#include "vcd-sound.h"
#include "vcd-display.h"
#include "../../../vcd-common-api/vcd-common.h"


static void change_pic2(GtkNotebook *notebook, GtkWidget *page, guint page_num);

static void change_pic2(GtkNotebook *notebook, GtkWidget *page, guint page_num)
{
    //GtkWidget *labelcurrent = gtk_notebook_get_tab_label(notebook, page);
    switch (page_num)
    {
    case 0:
        break;
    case 1: gdk_threads_add_idle((GSourceFunc)get_screenNum, NULL);
        break;
    case 2: gdk_threads_add_idle((GSourceFunc)set_sound_combo, NULL);
        //case 2: g_timeout_add(1, (GSourceFunc)set_sound_combo, NULL);
        break;
    case 3: break;
    }
}

GtkWidget* get_setting_main_notebook(void)
{
    GtkWidget *main_notebook;

    GtkWidget *label_sys_info;
    GtkWidget *label_display;
    GtkWidget *label_sound;
    GtkWidget *label_login_setting;
    GtkWidget *label_sys_upgrade;

    main_notebook  = gtk_notebook_new();
    gtk_notebook_set_tab_pos(GTK_NOTEBOOK(main_notebook), GTK_POS_TOP);//设置notebook标题栏的位置

    label_sys_info      = gtk_label_new("\n系统信息\n");
    label_display       = gtk_label_new("\n显示设置\n");
    label_sound         = gtk_label_new("\n声音设置\n");
    label_login_setting = gtk_label_new("\n登录设置\n");
    label_sys_upgrade   = gtk_label_new("\n系统升级\n");


    GtkWidget *sys_info_grid     = get_sys_info_grid();
    GtkWidget *grid_display      = gtk_sys_display_grid();
    GtkWidget *fix_sound         = get_sound_setting_fix();
    GtkWidget *fix_login_setting = get_login_setting_fix();
    GtkWidget *fix_upgrade       = get_upgrade_setting_fix();

    gtk_notebook_append_page(GTK_NOTEBOOK(main_notebook), sys_info_grid,       label_sys_info);
    gtk_notebook_append_page(GTK_NOTEBOOK(main_notebook), grid_display,        label_display);
    gtk_notebook_append_page(GTK_NOTEBOOK(main_notebook), fix_sound,           label_sound);
    gtk_notebook_append_page(GTK_NOTEBOOK(main_notebook), fix_login_setting,   label_login_setting);
    gtk_notebook_append_page(GTK_NOTEBOOK(main_notebook), fix_upgrade,         label_sys_upgrade);
    gtk_notebook_set_show_border((GtkNotebook *)main_notebook, FALSE);

    g_signal_connect(G_OBJECT(main_notebook),      "switch-page", G_CALLBACK(change_pic2),        NULL);

    set_css(label_sys_info, "label{border-radius:0px;}");
    set_css(label_display, "label{border-radius:0px;}");
    set_css(label_sound, "label{border-radius:0px;}");
    set_css(label_login_setting, "label{border-radius:0px;}");
    set_css(label_sys_upgrade, "label{border-radius:0px;}");

    set_css(main_notebook, "header{background:rgb(245,245,245);"
            "border-bottom:0px solid rgb(230,230,230)}");
    set_css(main_notebook, "notebook{background-color:rgb(255,255,255);"
            "border-bottom:none;"
            "border-radius:0px}");

    set_css(sys_info_grid, "grid{background-color:rgb(255,255,255);"
            "border-radius:0px}");
    set_css(grid_display, "grid{background-color:rgb(255,255,255);"
            "border-radius:0px}");

    return main_notebook;
}
